let _this = '';
let bottomTimer = null;
export const init = (params) => {
    _this = params._this;
}
export const sysInfo = uni.getSystemInfoSync();
export const loading = (title) => {
    uni.showLoading({
        title: title,
        mask: true,
        
    })
    _this.$store.state.loading = setTimeout(() => {
        console.log('定时器')
        uni.showToast({
            icon: 'none',
            title: '操作失败！',
            position: 'center'
        })
        uni.hideLoading()
    }, 100000)
}
export const successToast = (title) => {
    uni.showToast({
        title: title,
        icon: 'success'
    })
}
export const clearLoad = () => {
    uni.hideLoading()
    clearTimeout(_this.$store.state.loading);
}
export const bottomLoad = () => {
    _this.$store.state.bottomLoading = true;
    if(bottomTimer) {
        clearTimeout(bottomTimer);
    }
    bottomTimer = setTimeout(() => {
        _this.$store.state.bottomLoading = false;
    }, 100000)
}

export const timeDate = (time, format) => {
    let d = new Date(time);
    let YY = d.getFullYear();
    let MM = d.getMonth() > 8 ? d.getMonth() + 1 : '0' + (d.getMonth() + 1)
    let DD = d.getDate() > 9 ? d.getDate() : '0' + d.getDate()
    let hh = d.getHours() > 9 ? d.getHours() : '0' + d.getHours()
    let mm = d.getMinutes() > 9 ? d.getMinutes() : '0' + d.getMinutes()
    let ss = d.getSeconds() > 9 ? d.getSeconds() : '0' + d.getSeconds()
    switch(format) {
        case 'YY-MM-DD hh:mm:ss': 
            return `${YY}-${MM}-${DD} ${hh}:${mm}:${ss}`
    }
}
// export const dnsName = 'http://119.23.245.89:3003/';
// export const wsName = 'ws://119.23.245.89:3003/';
export const dnsName = 'http://127.0.0.1:3003/';
export const projectName = 'plantknow'